package com.burnerpat.fl2d.core.weapon;

import com.burnerpat.fl2d.core.Timer;
import com.burnerpat.fl2d.core.UpdatablePool;
import com.burnerpat.fl2d.core.ship.Ship;
import com.burnerpat.fl2d.math.Vector2D;

public class Weapon
{
	public static final long BASE_RPM = 120;
	
	private Prefix prefix = null;
	private Manufacturer manufacturer = null;
	private Model model = null;
	private Ammunition ammunition = null;
	
	private String name = "undefined";
	
	private Timer timer = null;
	
	private Ship owner = null;
	private Vector2D relativePosition = new Vector2D(0.0, 0.0);
	
	public Weapon(Ship pOwner, Vector2D pRelPos, Prefix pPrefix, Manufacturer pManufacturer, Model pModel, Ammunition pAmmunition)
	{
		owner = pOwner;
		relativePosition = pRelPos;
		
		prefix = pPrefix;
		manufacturer = pManufacturer;
		ammunition = pAmmunition;
		model = pModel;
		
		name = prefix.getName() + " " + manufacturer.getName() + " " + model.getName() + " " + ammunition.getName();
		
		timer = new Timer((long)((double)BASE_RPM * (1.0 + (manufacturer.getRateModifier() * (1.0 + model.getRateModifier())))));
	}
	
	public Ship getOwner()
	{
		return owner;
	}
	
	public Vector2D getRelativePosition()
	{
		return relativePosition;
	}
	
	public String getName()
	{
		return name;
	}
	
	public Prefix getPrefix()
	{
		return prefix;
	}
	
	public Manufacturer getManufacturer()
	{
		return manufacturer;
	}
	
	public Ammunition getAmmunition()
	{
		return ammunition;
	}
	
	public void fire()
	{
		if (timer.isOver())
		{
			//TODO: fire etc.
		}
	}
}
